home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / FWInk.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.3 KB  |  191 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWInk.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWINK_H
  13. #include "FWInk.h"
  14. #endif
  15.  
  16. #ifndef FWSTRMRW_H
  17. #include "FWStrmRW.h"
  18. #endif
  19.  
  20. #ifdef FW_BUILD_MAC
  21. #pragma segment FWGraphics_Ink
  22. #endif
  23.  
  24. //========================================================================================
  25. //    Template instantiation
  26. //========================================================================================
  27.  
  28. #include "FWGrRef.tpp"
  29.  
  30. FW_DEFINE_AUTO_TEMPLATE(FW_TGrRefPtr, FW_HInk)
  31.  
  32. #ifdef FW_USE_TEMPLATE_PRAGMAS
  33.  
  34. #pragma template_access public
  35. #pragma template FW_TGrRefPtr<FW_HInk>
  36.  
  37. #else
  38.  
  39. template class FW_TGrRefPtr<FW_HInk>;
  40.  
  41. #endif
  42.  
  43. //========================================================================================
  44. //    class FW_CInk
  45. //========================================================================================
  46.  
  47. FW_DEFINE_AUTO(FW_CInk)
  48.  
  49. //----------------------------------------------------------------------------------------
  50. //    FW_PrivAcquireGrRep
  51. //----------------------------------------------------------------------------------------
  52.  
  53. void FW_PrivAcquireGrRep(FW_HInk rep)
  54. {
  55.     if (rep != 0)
  56.         FW_PrivInk_Acquire(rep);
  57. }
  58.  
  59. //----------------------------------------------------------------------------------------
  60. //    FW_PrivReleaseGrRep
  61. //----------------------------------------------------------------------------------------
  62.  
  63. void FW_PrivReleaseGrRep(FW_HInk rep)
  64. {
  65.     if (rep != 0)
  66.         FW_PrivInk_Release(rep);
  67. }
  68.  
  69. //----------------------------------------------------------------------------------------
  70. //    FW_CInk::FW_CInk
  71. //----------------------------------------------------------------------------------------
  72.  
  73. FW_CInk::FW_CInk(const FW_SColor& foreColor, const FW_SColor& backColor, FW_TransferModes transferMode)
  74. {
  75.     FW_PlatformError error;
  76.     FW_HInk rep = FW_PrivInk_Create(foreColor, backColor, transferMode, &error);
  77.     FW_FailOnError(error);
  78.     SetRep(rep);
  79.     FW_END_CONSTRUCTOR
  80. }
  81.  
  82. //----------------------------------------------------------------------------------------
  83. //    FW_CInk::FW_CInk
  84. //----------------------------------------------------------------------------------------
  85.  
  86. FW_CInk::FW_CInk(FW_TransferModes transferMode)
  87. {
  88.     FW_PlatformError error;
  89.     FW_HInk rep = FW_PrivInk_Create(FW_kRGBBlack, FW_kRGBWhite, transferMode, &error);
  90.     FW_FailOnError(error);
  91.     SetRep(rep);
  92.     FW_END_CONSTRUCTOR
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. //    FW_CInk::FW_CInk
  97. //----------------------------------------------------------------------------------------
  98.  
  99. FW_CInk::FW_CInk(const FW_CInk& other) :
  100.     FW_TGrRefPtr<FW_HInk>(other)
  101. {
  102.     FW_END_CONSTRUCTOR
  103. }
  104.  
  105. //----------------------------------------------------------------------------------------
  106. //    FW_CInk::FW_CInk
  107. //----------------------------------------------------------------------------------------
  108.  
  109.  
  110. FW_CInk::FW_CInk(FW_EStandardInks std)
  111. {
  112.     FW_PlatformError error;
  113.     FW_HInk rep = FW_PrivInk_CreateStandard(std, &error);
  114.     FW_FailOnError(error);
  115.     SetRep(rep);
  116.     FW_END_CONSTRUCTOR
  117. }
  118.  
  119. //----------------------------------------------------------------------------------------
  120. //    FW_CInk::FW_CInk
  121. //----------------------------------------------------------------------------------------
  122.  
  123. FW_CInk::~FW_CInk()
  124. {
  125.     FW_START_DESTRUCTOR
  126. }
  127.  
  128. //----------------------------------------------------------------------------------------
  129. //    FW_CInk::operator=
  130. //----------------------------------------------------------------------------------------
  131.  
  132. FW_CInk& FW_CInk::operator=(const FW_CInk& other)
  133. {
  134.     FW_TGrRefPtr<FW_HInk>::operator=(other);
  135.     return *this;
  136. }
  137.  
  138. //----------------------------------------------------------------------------------------
  139. //    FW_CInk::operator=
  140. //----------------------------------------------------------------------------------------
  141.  
  142. FW_CInk& FW_CInk::operator=(FW_EStandardInks std)
  143. {
  144.     FW_PlatformError error;
  145.     FW_HInk rep = FW_PrivInk_CreateStandard(std, &error);
  146.     FW_FailOnError(error);
  147.     SetRep(rep);
  148.     return *this;
  149. }
  150.  
  151. //----------------------------------------------------------------------------------------
  152. //    FW_CInk::Copy
  153. //----------------------------------------------------------------------------------------
  154.  
  155. FW_CInk FW_CInk::Copy() const
  156. {
  157.     FW_PlatformError error;
  158.     FW_HInk rep = FW_PrivInk_Copy(fRep, &error);
  159.     FW_FailOnError(error);
  160.     
  161.     FW_CInk ink;
  162.     ink.SetRep(rep);
  163.     return ink;
  164. }
  165.  
  166. //----------------------------------------------------------------------------------------
  167. //    operator <<
  168. //----------------------------------------------------------------------------------------
  169.  
  170. FW_CWritableStream& operator << (FW_CWritableStream& stream, const FW_CInk& ink)
  171. {
  172.     FW_PlatformError error;
  173.     FW_PrivInk_Write(ink.fRep, stream, &error);
  174.     FW_FailOnError(error);
  175.     return stream;
  176. }
  177.  
  178. //----------------------------------------------------------------------------------------
  179. //    operator >>
  180. //----------------------------------------------------------------------------------------
  181.  
  182. FW_CReadableStream& operator >> (FW_CReadableStream& stream, FW_CInk& ink)
  183. {
  184.     FW_PlatformError error;
  185.     FW_HInk rep = FW_PrivInk_Read(stream, &error);
  186.     FW_FailOnError(error);
  187.     ink.SetRep(rep);
  188.     return stream;
  189. }
  190.  
  191.